package com.eascs.admin.o2o.loan.notify.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.stereotype.Service;

import com.eascs.admin.o2o.internal.util.StatusContexts;
import com.eascs.admin.o2o.loan.entity.O2oLoanapplyEntity;
import com.eascs.admin.o2o.loan.notify.O2OMsgNotifyService;
import com.eascs.app.log.Logger;
import com.eascs.app.log.LoggerFactory;
import com.eascs.workflow.common.entity.wf.ProcessTaskMain;
import com.eascs.workflow.common.entity.wf.ProcessTemplate;
import com.eascs.workflow.common.vo.ModelResult;
import com.eascs.workflow.common.vo.WFNotifyParam;

/**
 * 归档流程
 */
@Service
public class GDMsgNotifyServiceImpl implements O2OMsgNotifyService {
	private static Logger log = LoggerFactory.getLogger(GDMsgNotifyServiceImpl.class);

	@Override
	public ModelResult<O2oLoanapplyEntity> notify(WFNotifyParam notifyParam, O2oLoanapplyEntity loanapply){
		ModelResult<O2oLoanapplyEntity> modelResult =new ModelResult<>();
		log.info("启动归档流程通知:[{}]", StatusContexts.WFTYPE_TYPE_PLACE_ON_FILE);
		if (notifyParam.getProcessStatus() == ProcessTaskMain.PROECESS_STATUS_PASS) {
			log.info("归档流程通过记录通知：{}", loanapply.getBillCode());
			loanapply.setIsPlaceOnFile(StatusContexts.WFTYPE_STATUS_CLO);
			loanapply.setPlaceOnFileTime(new Date());
		} else if (notifyParam.getProcessStatus() == ProcessTaskMain.PROECESS_STATUS_TURNED_DOWN) {
			log.info("归档流程驳回记录通知：{}", loanapply.getBillCode());
			loanapply.setIsPlaceOnFile(StatusContexts.O2O_NEW);
		} else if (notifyParam.getProcessStatus().equals(ProcessTaskMain.PROECESS_STATUS_REJECT)) {
			log.info("归档流程作废记录通知：{}", loanapply.getBillCode());
		}
		modelResult.withModel(loanapply);
		return modelResult;
	}

	@Override
	public List<String> getServiceName() {
		ArrayList<String> list = new ArrayList<String>();
		list.add(ProcessTemplate.PROECESS_TYPE_ARCHIVE);
		list.add(ProcessTemplate.PROECESS_TYPE_PLACE_ON_FILE);
		return list;
	}

	@Override
	public Boolean checkReturn() {
		return Boolean.FALSE;
	}
	
}
